#include "main.h"

NUChat *client;
Server *server;
int main (int argc, char * const argv[])
{
	server = NULL;
	client = NULL;

#ifdef __WIN32__
	WSADATA wsaData;

	/* check for error */
	if ( WSAStartup( MAKEWORD( 2, 0 ) , &wsaData ) != 0 ) return FALSE;

#else
//	signal(SIGWINCH, resize);
//	signal(SIGKILL, terminate);
#endif

	if (argc > 1 && !strcmp(argv[1], "server"))
{

		server = new Server(1, argc, argv, false);
		server->run();

	} else {

		if (argc == 2)
			client = new NUChat(argv[1]);
		else
			client = new NUChat();
		client->run();
	}

	system("PAUSE");
	return 0;
}

/*
void terminate(int sig)
{
	// Yes, first ctl-c will end any client,
	// second ctl-c will end the server.
	if (client) client->disconnect;
	else if (server) server->disconnect;
}

void resize(int sig)
{
	client->resize();
}
*/
